<template>
	<view class="common-list">
		<view class="common-list-left">
			<image :src="item.userpic" mode="widthFix" lazy-load></image>
		</view>
		<view class="common-list-right">
			<view class="common-list-header flex-sp-ac">
				<view class="flex-sp-ac">
					<text>{{item.username}}</text>
					<view class="icon iconfont" :class="(item.sex==1?'icon-nv':'icon-nan')">
						{{item.age}}</view>
				</view>
				<view>
					<view v-if="!item.isFollow" class="concern" @tap="concernChange(item)">
						<view class="icon iconfont icon-zengjia">
							关注
						</view>
					</view>
					<view v-if="item.isFollow" class="unconcern" @tap="concernChange(item)">
						已关注
					</view>
					<!-- <view class="icon iconfont icon-zengjia">
						关注
					</view> -->
				</view>
			</view>
			<view class="common-list-title">
				{{item.title}}
			</view>
			<view class="common-list-content flex-sc-ac">
				<image v-if="item.titlePic" :src="item.titlePic" mode="widthFix" lazy-load></image>
				<!-- 视频 -->
				<template v-if="item.video">
					<view class="common-list-play icon iconfont icon-bofang"></view>
					<view class="common-list-playinfo">
						{{item.video.lookNum}} 次播放 {{item.video.long}}
					</view>
				</template>
				<!-- 分享 -->
				<template v-if="item.share">
					<view class="common-list-share flex-ac">
						<image :src="item.share.titlePic" mode="widthFix" lazy-load>
						</image>
						<view>{{item.share.title}}</view>
					</view>
				</template>
			</view>
			<view class="common-list-footer flex-sp-ac">
				<view>
					{{item.path}}
				</view>
				<view class="flex-ac">
					<view class="icon iconfont icon-zhuanfa">{{item.shareNum}}</view>
					<view class="icon iconfont icon-pinglun1">{{item.commonNum}}</view>
					<view class="icon iconfont icon-dianzan">{{item.goodNum}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		props:{
			item:Object,
			index:Number
		},
		methods:{
			concernChange(item) {
				item.isFollow = !item.isFollow;
				if (item.isFollow == true) {
					uni.showToast({
						title: '关注成功'
					});
				}else{
					uni.showToast({
					    title: '取消关注'
					});
				}
			}
		}
	}
</script>

<style scoped>
	.common-list {
		padding: 20rpx;
		display: flex;
	}
	
	.common-list-left {
		flex-shrink: 0; 
		/* 不会被压缩 */
	}
	
	.common-list-left>image {
		width: 90rpx;
		height: 120rpx;
		border-radius: 100%;
	}
	
	.common-list-right {
		/*border: 1px solid;*/
		margin-left: 15rpx;
		flex: 1;
		/* 占用剩余的所有空间 */
		border-bottom: 1rpx solid #F2F2F2;
		padding-bottom: 15rpx;
	}
	
	.common-list-header>view:nth-child(1) text {
		color: #BABABA;
		font-weight: bold;
	}
	
	.icon-nv{
		background-color: #FF6B8D;
		color: white;
		padding: 5rpx 12rpx;
		font-size: 23rpx;
		border-radius: 20rpx;
		margin-left: 15rpx;
		line-height: 22rpx;
	}
	/* .common-list-header>view:nth-child(1) view  */
	.icon-nan{
		background-color: #007AFF;
		color: white;
		padding: 5rpx 12rpx;
		font-size: 23rpx;
		border-radius: 20rpx;
		margin-left: 15rpx;
		line-height: 22rpx;
	}
	
	/* .common-list-header>view:nth-child(2) view {
		background-color: #f4f4f4;
		border-radius: 8rpx;
		padding: 5rpx 15rpx;
		font-size: 30rpx;
	} */
	
	.common-list-title {
		font-size: 35rpx;
		padding: 15rpx 0;
		font-weight: 600;
	}
	
	/* 视频 */
	
	.common-list-content {
		position: relative;
	}
	
	.common-list-content>image {
		width: 100%;
		border-radius: 10rpx;
		margin-bottom: 20rpx;
	}
	
	.common-list-play {
		position: absolute;
		font-size: 180rpx;
		color: white;
	}
	
	.common-list-playinfo {
		position: absolute;
		color: white;
		right: 10rpx;
		bottom: 25rpx;
		font-size: 28rpx;
		border-radius: 20rpx;
		background-color: rgba(51, 51, 51, 0.70);
		padding: 6px 15rpx;
		line-height: 25rpx;
	}
	
	/* \视频 */
	
	.common-list-footer view {
		color: #BABABA;
		font-size: 25rpx;
	}
	
	.common-list-footer>view:nth-child(2) view {
		margin-left: 15rpx;
	}
	
	/* 分享 */
	
	.common-list-share {
		background-color: #F1F1F1;
		padding: 15rpx 5rpx;
		border-radius: 10rpx;
		width: 100%;
	}
	
	/* 使用flex布局时，子元素的宽度的设置可能会失效 
		flex-grow:是否自动增长空间
		flex-shrink:是否自动缩小空间，默认值为1，表示自动缩小
	*/
	.common-list-share>image {
		width: 35%;
		margin-right: 15rpx;
		border-radius: 15rpx;
	}
	
	.common-list-share>view {
		/* flex-shrink: 0; */
	}
	
	/* \分享 */
	
	
	 .concern {
		background-color:#09BB07;
		color: #F1F1F1;
		display: flex;
		align-items: center;
		border-radius: 6%;
		padding: 7rpx;
		margin-right: 10rpx;
	}
	
	.unconcern{
		background-color:#FFB846;
		color: #F1F1F1;
		display: flex;
		align-items: center;
		border-radius: 6%;
		padding: 7rpx;
		margin-right: 10rpx;
	} 
</style>
